const uniObj_category = uniCloud.importObject("sm-category-obj",{
	//customUI: true // 取消自动展示的交互提示界面
});
const state = {
	categoryList:[],
	dataList:[],
	categoryInfo:{},
	imageList:[],
	searchList:[],
	hotSell:[],
	allCateList:[]
};
const mutations={
	GETALLCATE(state,allCateList){
		state.allCateList = allCateList;
	},
	GETGORYLISTLEVEL01(state,categoryList){
		state.categoryList = categoryList;
	},
	GETGORYLISTLEVEL02(state,dataList){
		state.dataList = dataList;
	},
	GETGORYHOT(state,dataList){
		state.dataList = dataList;
	},
	GETGORYINFO(state,res){
		state.categoryInfo = res.data;
		state.imageList = res.imageList;
	},
	SEARCHCATEGORY(state,res){
		state.searchList = res.data;
	},
	GETHOTSELL(state,res){
		state.hotSell = res.data;
	}
};
const actions={
	async getAllCate({commit}){
		const res = await uniObj_category.getAllCate();
		if(res.code==0){
			commit("GETALLCATE",res.data);
		}
	},
	// 获取一级分类列表
	async getCategoryListLevel01({commit}){
		const res = await uniObj_category.getCategoryListLevel01();
		if(res.code==0){
			commit("GETGORYLISTLEVEL01",res.data);
		}
	},
	async getCategoryListLevel02({commit},id){
		const res = await uniObj_category.getCategoryListLevel02(id);
		if(res.code==0){
			commit("GETGORYLISTLEVEL02",res.data);
		}
	},
	async getCategoryHot({commit}){
		const res = await uniObj_category.getCategoryHot();
		if(res.code==0){
			commit("GETGORYHOT",res.data);
		}
	},
	async getCategoryInfo({commit},_id){
		const res = await uniObj_category.getCategoryInfo(_id);
		if(res.code==0){
			commit("GETGORYINFO",res);
		}
	},
	async searchCategory({commit},keyword){
		const res = await uniObj_category.searchCategory(keyword);
		if(res.code==0){
			commit("SEARCHCATEGORY",res);
		}
	},
	async getHotSell({commit}){
		const res = await uniObj_category.getHotSell();
		if(res.code==0){
			commit("GETHOTSELL",res);
		}
	}
};
const getters={};
export default {
	state,
	mutations,
	actions,
	getters
}